//
//  SettingUserMessageHeaderView.m
//  much
//
//  Created by Believer Just on 2019/1/9.
//  Copyright © 2019年 iOS. All rights reserved.
//

#import "SettingUserMessageHeaderView.h"

@interface SettingUserMessageHeaderView ()

@property (nonatomic, strong) UIImageView *userHeaderImageView;
@property (nonatomic, strong) UILabel *userNameLabel;

@end

@implementation SettingUserMessageHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}


#pragma mark - method
- (void)initView {
    [self.userHeaderImageView sd_setImageWithURL:[NSURL URLWithString:USER.userBaseInfo.infoModel.avatarImagePath] placeholderImage:IMAGE_NAME(@"user_home_userHeader")];
    self.userNameLabel.text = @"编辑头像";
}
- (void)clickView {
    if (self.settingUserMessageHVBlock) {
        self.settingUserMessageHVBlock();
    }
}


#pragma mark - setting
- (void)setUploadUserHeaderImage:(BOOL)uploadUserHeaderImage {
    _uploadUserHeaderImage = uploadUserHeaderImage;
    
    [self.userHeaderImageView sd_setImageWithURL:[NSURL URLWithString:USER.userBaseInfo.infoModel.avatarImagePath] placeholderImage:IMAGE_NAME(@"user_home_userHeader")];
}


#pragma mark - 懒加载
- (UIImageView *)userHeaderImageView {
    if (!_userHeaderImageView) {
        _userHeaderImageView = [UIImageView new];
        _userHeaderImageView.cornerRadius = 35.5;
        [self addSubview:_userHeaderImageView];
        [_userHeaderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(self).with.offset(25);
            make.width.and.height.mas_equalTo(71);
        }];
        
        [_userHeaderImageView tapUpWithBlock:^(UIView *v) {
            [self clickView];
        }];
    }
    return _userHeaderImageView;
}
- (UILabel *)userNameLabel {
    if (!_userNameLabel) {
        _userNameLabel = [UILabel new];
        _userNameLabel.textColor = Color34;
        _userNameLabel.textAlignment = NSTextAlignmentCenter;
        _userNameLabel.font = APPFONT(14);
        [self addSubview:_userNameLabel];
        [_userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(self.userHeaderImageView.mas_bottom).with.offset(10);
        }];
    }
    return _userNameLabel;
}

@end
